I got a problem...i create a attribute named Applicability,with the options: L450, L500
Object obj = current
int iQE
string currentQE
/*===========================================================================================
Interface Items
==========================================================================================*/
DB verEvidenceBox = create("??????????????? Checklist", styleFloating)
DBE newReportButton, nextButton, prevButton
DBE tagField
DBE selectChoiceQE
DBE richTextReq,textMultiLine
/*===========================================================================================
Answer Types
==========================================================================================*/
string optionsE[] = {"Valid", "Not Valid", "Not Evaluated"}
string errMess = "Error creating type."
AttrType answerType2 = find(current Module, "AnswerE")
if (null answerType2) answerType2 = create ("AnswerE", optionsE, errMess)
/*===========================================================================================
Creates attributes necessary to validate.
==========================================================================================*/
void createValidationAttr(string typeName, string aName){
AttrDef ad = find(current Module, aName)
if(null ad) create object type typeName (default "Not Evaluated") changeBars false attribute aName
else // print "Attr Def '" aName "' already exists.\n"
}
// Attributes: "Validation Qn"
createValidationAttr("AnswerE", "Validation Ensure")
if(!exists attribute "Checker") create type "Text" changeBars false attribute "Checker"
if(!exists attribute "Author") create type "Text" changeBars false attribute "Author"
/*========================================================================================
Functions
==========================================================================================*/
void deleteAttrDef(string s){
AttrDef ad = find(current Module, s)
if (null ad) // print "Attr Def '" s "' does not exist.\n"
else delete(ad)
}
void deleteAttrType(string s){
string err = ""
AttrType at = find(current Module, s)
if (null at) // print "Attr Type '" s "' does not exist.\n"
else delete(at, err)
}
// Return the last author of the current object
string lastObjectTextModifier(){
History h
string lastAuthor = ""
for h in current Object do {
HistoryType ht = h.type
if (ht == modifyObject && h.attrName == "Object Text") lastAuthor = h.author
}
return lastAuthor
}
// Test if 'Author' is the same as 'Checker' (actual user).
bool isAuthor(){
User u = find() // returns current user login.
string userLogin = u.name
if(exists attribute "Author"){ // Avoid errors
if(userLogin == obj."Author" "") return true
}
return false
}
void updateVariables() {
string currentQE = obj."Validation Ensure" ""
for iQE in 0:2 by 1 do {
if (currentQE == answerType2.strings[iQE]) { break }
iQE++
}
set(tagField, identifier(obj))
set(selectChoiceQE,iQE)
if(null obj."Object Text" "") set(richTextReq, "<Title>") // Avoid headings.
else set(richTextReq, obj."Object Text" "")
refresh current Module
}
void verifyApplicability(){
if(!isMember(obj."Applicability", "L450")) {
warningBox "The requirement ??????????????????????????, therefore does not need validation."
}
}
void updateVariables1() {
verifyApplicability() // Inform if this requirement cannot be validated.
string currentQE = obj."Validation Ensure" ""
for iQE in 0:2 by 1 do {
if (currentQE == answerType2.strings[iQE]) { break }
iQE++
}
set(tagField, identifier(obj))
set(selectChoiceQE,iQE)
if(null obj."Object Text" "") set(richTextReq, "<Title>") // Avoid headings.
else set(richTextReq, obj."Object Text" "")
refresh current Module
}
bool notExistAttribute(string aName){
AttrDef ad = find(current Module, aName)
if (null ad) return true
else return false
}
// Save all validation questions and Validation Comments
void saveObjects(){
string aux = ""
int i
bool wasModified = false
if(canModify(obj)){
if(!isMember(obj."Applicability", "L450")) {
if (get(selectChoiceQE) =="Valid" || get(selectChoiceQE)=="Not Valid" || get(selectChoiceQE)=="Not Evaluated"){
return wasModified = false
}
}
aux = get(selectChoiceQE)
if(obj."Validation Ensure" "" != aux) {
obj."Validation Ensure" = aux
wasModified = true
}
// Save checker
if(wasModified){ // Saves Checker just if something has changed.
User u = find() // returns current user login.
string uName = u.name
if(obj."Object Heading" "" == "") obj."Checker" = uName// just save if is requirement.
}
}
else infoBox "Cannot modify current object."
}
void saveReport(DB calledFrom){
saveObjects() // Saves all validation questions and Validation Comments.
save(current Module)
refresh (current Module)
}
void closeBox(DB calledFrom){
if(unsaved(current Module)){
string buttons[] = {"Yes", "No"}
int answer = messageBox("To save the validation, save current module. \nSave current module?", buttons, msgWarning)
if(buttons[answer] == "Yes") {
saveObjects() // Saves all validation questions and Validation Comments.
save(current Module)
refresh (current Module)
}
}
hide calledFrom
}
void selectNext(DB calledFrom) {
saveObjects() // Save all validation questions and Validation Comments
// go to next object and Check if module is in exclusive edit or not.
if (!null (next obj)&&(canModify(next obj))) {
obj = next(obj)
current = obj
updateVariables()
updateVariables1()
}
else{
infoBox "Open module as Shareable or Exclusive Edit."
}
}
void selectPrev(DB calledFrom) {
saveObjects() // Save all validation questions and Validation Comments
// go back to previous object and Check if module is in exclusive edit or not.
if (!null (previous obj)&&(canModify(previous obj))) {
obj = previous(obj)
current = obj
updateVariables()
updateVariables1()
}
else{
infoBox "Open module as Shareable or Exclusive Edit."
}
}
bool notExistAttribute(string attrName){
AttrDef ad = find(current Module, attrName)
if (null ad) return true
else {
// print "Attribute '" attrName "' alredy exists. Could not create.\n"
return false
}
}
// Some checks to init GUI.
bool canInit(){
// Check if module has requirements.
if(null obj) {
infoBox "Module without requirements to validate."
return false
}
// Check if module is in exclusive edit or not.
if(!canModify(current Object)){
infoBox "Open module as Shareable or Exclusive Edit."
return false
}
return true
}
/*========================================================================================
Main Program
==========================================================================================*/
// Start to buid GUI
if(canInit()){
// Creation of Buttons and function associated to 'close'
prevButton = apply(verEvidenceBox, "<<&Previous Req", selectPrev)
nextButton = apply(verEvidenceBox, "&Next Req>>", selectNext)
saveButton = apply(verEvidenceBox, "&Save Module", saveReport)
close(verEvidenceBox, true, closeBox)
// Shows Proposed Checker, Tag and Requirement
tagField = field(verEvidenceBox, "Tag:", identifier(obj), 20, true)
tagField->"left"->"unattached"
tagField-> "top"-> "form"
richTextReq = richText(verEvidenceBox, "", obj."Object Text" "" , 80, true) // Shows the requirement "Object Text"
label (verEvidenceBox, "?????????????????????????????????????????????????????????????????.\n"
)
// Questions
selectChoiceQE = choice(verEvidenceBox, "Is the ?????????????????????? considering the above conditions?", optionsE, 1, 13,false)
updateVariables()
updateVariables1()
show verEvidenceBox
}
Bruwbruw - Thu Mar 01 12:42:53 EST 2012 |